package com.myiam.idm.core.services.impl;

import java.util.List;

import com.myiam.idm.core.model.Account;
import com.myiam.idm.core.model.Password;
import com.myiam.idm.core.services.AccountService;
import com.myiam.idm.core.services.exceptions.AccountCreateException;
import com.myiam.idm.core.services.impl.helper.ModelToMetaModel;
import com.myiam.idm.meta.dao.AccountRepository;
import com.myiam.idm.meta.dao.IdentityRepository;
import com.myiam.idm.meta.model.MmAccount;
import com.myiam.idm.meta.model.MmIdentity;

public class AccountServiceImpl implements AccountService {

	private IdentityRepository identRepo=null;
	private AccountRepository  accountRepo=null;
	
	@Override
	public void create(Account account, long identityId)
			throws AccountCreateException {

		// validate ident
		MmIdentity identity = identRepo.findById(identityId);
		
		
		if (identity == null) {
			throw new AccountCreateException();
		} 
		
		MmAccount metaAccount = ModelToMetaModel.accountM2MM(account);
		
		accountRepo.create(metaAccount);
		
		
		
		
		
	}

	@Override
	public Password generatePassword() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Account> getAccountsForIdentity(long id) {
		// TODO Auto-generated method stub
		return null;
	}

}
